from pytesser3 import *
from xjlibrary.our_file_dir import BaseDir


class TesserImage():

    def __init__(self):
        pass

    def tesser_from_pytesser(self,filePath):
        """
        识别图片中的文字
        :param filePath:
        :return:
        """
        image = Image.open(filePath)
        # print(image_to_string(image))
        return image_to_string(image)

    def image_file_to_strings(self,filePath):
        # print(image_file_to_string(filePath))
        return image_file_to_string(filePath)


# TesserImage().tesser_from_pytesser(".\login.png")
path = BaseDir.get_file_dir_absolute(__file__)
filepath = BaseDir.get_new_path(path,"login.png")
print(filepath)
image = Image.open(filepath)

print(image_to_string(image))


